﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using PMP.Core.Enums;
using SqlSugar;

namespace PMP.Core.Entities;

/// <summary>
/// 离线账户
/// </summary>
public class TbAccount : BaseEntity
{
    /// <summary>
    /// 用户名
    /// </summary>
    public string UserName { get; set; }
    /// <summary>
    /// 密码
    /// </summary>
    [JsonIgnore]
    public string Password { get; set; }
    /// <summary>
    /// 姓名
    /// </summary>
    public string RealName { get; set; }

    /// <summary>
    /// 性别
    /// </summary>
    public string Sex { get; set; } = "";
    /// <summary>
    /// 手机号
    /// </summary>
    public string PhoneNumber { get; set; }= "";
    /// <summary>
    /// 邮箱
    /// </summary>
    public string Email { get; set; }= "";
    /// <summary>
    /// 籍贯
    /// </summary>
    public string NativePlace { get; set; }= "";
    /// <summary>
    /// 出生年月
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public DateTime? DateOfBirth { get; set; }

    /// <summary>
    /// 推荐人ID
    /// </summary>
    public int ReferrerUserId { get; set; } = 0;
    // /// <summary>
    // /// 上级ID
    // /// </summary>
    // public int SuperiorUserId { get; set; } = 0;

    /// <summary>
    /// 用户类型
    /// </summary>
    public EnumUserLevel UserLevel { get; set; } = EnumUserLevel.Level0;
    /// <summary>
    /// 用户等级更新时间
    /// </summary>
    public DateTime UserLevelUpdateTime { get; set; } = DateTime.Now;
    /// <summary>
    /// 标签
    /// </summary>
    [SugarColumn(IsJson = true)]
    public List<string> Tags { get; set; } = new();

    /// <summary>
    /// 用户介绍
    /// </summary>
    [SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string Introduction { get; set; } = "";

    /// <summary>
    /// 是否是超级管理员
    /// </summary>
    public bool IsSuperAdmin { get; set; } = false;
    
    /// <summary>
    /// 人员附件
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(TbAccountAttachment.AccountId))]
    public List<TbAccountAttachment> Attachments { get; set; } 
}